package com.software.graduationproject.modules.user.entity;

import cn.hutool.core.date.DatePattern;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.v2coding.validate.CreateGroup;
import com.v2coding.validate.UpdateGroup;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.v2coding.mybatis.model.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;
import java.math.BigDecimal;

/**
 * User : 系统用户表
 * ---------------------------------------------------------------------------------------------------------------------
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("user")
@ApiModel(value = "User", description = "系统用户表")
public class User extends BaseModel<User> {

    @TableField(value ="nickname")
    @ExcelProperty(value = "用户昵称")
    @ApiModelProperty(value = "用户昵称")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "用户昵称长度不能超过255")
    private String nickname;

    @TableField(value ="mobile")
    @ExcelProperty(value = "手机号码")
    @ApiModelProperty(value = "手机号码")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "手机号码长度不能超过255")
    private String mobile;

    @TableField(value ="description")
    @ExcelProperty(value = "备注")
    @ApiModelProperty(value = "备注")
    @Size(groups = {CreateGroup.class, UpdateGroup.class}, max = 255, message = "备注长度不能超过255")
    private String description;

    @TableField(value ="limitation")
    @ExcelProperty(value = "账号时限")
    @ApiModelProperty(value = "账号时限")
    @JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date limitation;

    @TableField(value ="pic_url")
    @ExcelProperty(value = "用户头像")
    @ApiModelProperty(value = "用户头像")
    private String picUrl;

    @TableField(value ="birthday")
    @ExcelProperty(value = "生日")
    @ApiModelProperty(value = "生日")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN, timezone = "GMT+8")
    @DateTimeFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private Date birthday;

}
